package com.spzx.product.controller;



import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.spzx.domain.Brand;
import com.spzx.product.service.IBrandService;
import com.spzx.vo.Result;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@Tag(name = "品牌接口管理")
@RestController
@RequestMapping("/brand")
public class BrandController {

    @Autowired
    private IBrandService brandService;

    @PostMapping("/brand")
    @Schema(description = "添加品牌")
    public Result addBrand(@Parameter Brand brand){
        brandService.addBrand(brand);
        return Result.build(null,200,"新增品牌成功");
    }
    //修改品牌

    @PutMapping("/brand")
    @Schema(description = "修改品牌")
    public Result updateBrand(@Parameter Brand brand) {
        brandService.updateById(brand);
        return Result.build(null,200,"修改品牌成功");
    }

    @DeleteMapping(value = "/brand/{ids}")
    @Schema(description = "删除品牌")
    public Result deleteBrand(@Parameter Long id) {
        brandService.removeById(id);
        return Result.build(null,200,"删除品牌成功");
    }
    //分页查询品牌
    @GetMapping("/list/{page}/{size}")
    @Schema(description = "查询品牌分页")
    public Result<Page<Brand>> getBrandList(@PathVariable Integer page, @PathVariable Integer size){
        return Result.build(brandService.getBrandList(page,size),200,"查询品牌分页成功");
    }
    //获取品牌详细信息
    @GetMapping(value = "/brand/{id}")
    public Result<Brand> getBrandById(@PathVariable Long id) {
        return Result.build(brandService.getById(id),200,"获取品牌详细信息成功");
    }
}
